﻿<local:StructViewBase 
    x:Class="AdminModule.UserControls.StructView.GradationsStruct"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:common="clr-namespace:System.Windows;assembly=System.Windows.Controls"
    xmlns:classes="clr-namespace:AdminModule.CustomXAMLElements"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:converters="clr-namespace:AdminModule.Converters"
    xmlns:validation="clr-namespace:InpValidator"
    xmlns:vm="clr-namespace:AdminModule.ViewModels"
    xmlns:local="clr-namespace:AdminModule.UserControls.StructView">

    <local:StructViewBase.Resources>
        <vm:CommonVM2 x:Key="commonVM"></vm:CommonVM2>
        <converters:BoolToVisibilityConverter x:Key="boolToVisibilityConverter"></converters:BoolToVisibilityConverter>
        <converters:NullToBlankConverter x:Key="nullToBlankConverter"></converters:NullToBlankConverter>

        <common:HierarchicalDataTemplate x:Key="otherGradation" ItemsSource="{Binding Path=Childs2, Mode=TwoWay}">
            <StackPanel Visibility="{Binding IsVisibility, Converter={StaticResource boolToVisibilityConverter}, Mode=TwoWay}" Orientation="Horizontal">
                <TextBox ToolTipService.ToolTip="Номер градации" BorderThickness="0" Padding="0" Text="{Binding Path=Order, Mode=TwoWay}">
                    <validation:ValidatorService.Validator>
                        <validation:NotEmptyValidator Init="InitValidator" />
                    </validation:ValidatorService.Validator>
                </TextBox>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Padding="0" Text=". "/>
                    <TextBlock Padding="0" Text="{Binding Path=Name}" />
                    <TextBlock Padding="0" Text=" (вес: "/>
                    <TextBox Padding="0" BorderThickness="0" FontWeight="Bold" Text="{Binding Path=Weight, Mode=TwoWay}" />
                    <TextBlock Padding="0" Text=")"/>

                    <ToolTipService.ToolTip>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="IDGradationTerm: "></TextBlock>
                            <TextBlock Text="{Binding IDGradationTerm}"></TextBlock>
                            <TextBlock Text=", "></TextBlock>
                            <TextBlock Text="IDGradation: "></TextBlock>
                            <TextBlock Text="{Binding Path=ID}"></TextBlock>
                        </StackPanel>
                    </ToolTipService.ToolTip>
                </StackPanel>
            </StackPanel>
        </common:HierarchicalDataTemplate>

        <common:HierarchicalDataTemplate x:Key="mainGradation" ItemsSource ="{Binding Path=Childs2, Mode=TwoWay}" ItemTemplate="{StaticResource otherGradation}">
            <StackPanel Visibility="{Binding IsVisibility, Converter={StaticResource boolToVisibilityConverter}, Mode=TwoWay}" Orientation="Horizontal">
                <TextBox FontStyle="Italic" ToolTipService.ToolTip="Номер группы" BorderThickness="0" Padding="0" Text="{Binding Path=Order, Mode=TwoWay}">
                    <validation:ValidatorService.Validator>
                        <validation:NotEmptyValidator Init="InitValidator" />
                    </validation:ValidatorService.Validator>
                </TextBox>
                <StackPanel Orientation="Horizontal">
                    <TextBlock FontStyle="Italic" Padding="0" Text=". "/>
                    <TextBlock FontStyle="Italic" Padding="0" Text="{Binding Path=Name}" />
                    <ComboBox Tag="{Binding}" ToolTipService.ToolTip="Единица измерения" Margin="5,0,0,0" Background="{x:Null}" BorderThickness="1" BorderBrush="#ffd9d9d9" SelectionChanged="unitComboBox_SelectionChanged" Loaded="unitComboBox_Loaded" DisplayMemberPath="Name" x:Name="unitComboBox" ItemsSource="{Binding Units, Source={StaticResource commonVM}, Mode=TwoWay}">
                        <!--<ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock MinHeight="17" Text="{Binding Name}">
                                    <ToolTipService.ToolTip>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="IDUnit: "></TextBlock>
                                            <TextBlock Text="{Binding IDUnit}"></TextBlock>
                                        </StackPanel>
                                    </ToolTipService.ToolTip>
                                </TextBlock>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>-->
                    </ComboBox>

                    <ToolTipService.ToolTip>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="IDGradationTerm: "></TextBlock>
                            <TextBlock Text="{Binding IDGradationTerm}"></TextBlock>
                            <TextBlock Text=", "></TextBlock>
                            <TextBlock Text="IDGradation: "></TextBlock>
                            <TextBlock Text="{Binding Path=ID}"></TextBlock>
                        </StackPanel>
                    </ToolTipService.ToolTip>
                </StackPanel>
            </StackPanel>
        </common:HierarchicalDataTemplate>

        <common:HierarchicalDataTemplate x:Key="GragationsRootLevel" ItemsSource ="{Binding Path=Childs2, Mode=TwoWay}" ItemTemplate="{StaticResource mainGradation}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Padding="0" Loaded="TextBlock_Loaded" Text="{Binding Path=Name, Mode=TwoWay}" FontWeight="Bold" />
            </StackPanel>
        </common:HierarchicalDataTemplate>
    </local:StructViewBase.Resources>

</local:StructViewBase>
